package com.report.controller;

import cn.hutool.core.convert.Convert;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.report.dto.request.ReportImageReq;
import com.report.dto.response.ReportImageRes;
import com.report.service.ReportImageService;
import com.zmh.framework.config.BaseCommonInterface;
import com.zmh.framework.util.Result;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * @author summer
 * @version 1.0
 * @date 2024/8/1 13:55
 */
@RestController
@RequestMapping(value = "/image")
@AllArgsConstructor
public class ReportImageController implements BaseCommonInterface<ReportImageReq, ReportImageRes> {

    private final ReportImageService reportImageService;

    @Override
    public Result<String> save(@Valid ReportImageReq reportImageReq) {
        reportImageService.saveReportImage(reportImageReq);
        return Result.successResult();
    }

    @Override
    public Result<String> del(Integer id) {
        reportImageService.removeById(id);
        return Result.successResult();
    }

    @Override
    public Result<Page<ReportImageRes>> lists(ReportImageReq reportImageReq) {
        Page<ReportImageRes>  page=reportImageService.lists(reportImageReq);
        return Result.successResult(page);
    }

    @Override
    public Result<ReportImageRes> findById(Integer id) {
        return Result.successResult(Convert.convert(ReportImageRes.class,reportImageService.getById(id)));
    }

    @Override
    public Result<String> batchDel(List<ReportImageRes> list) {
        return null;
    }
}
